package com.jerry.huihome.module.find.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jerry.huihome.R;
import com.jerry.huihome.base.BaseApplication;
import com.jerry.huihome.base.BaseViewHolder;
import com.jerry.huihome.base.MyBaseAdapter;
import com.jerry.huihome.module.find.entity.DesignerWorks;
import com.jerry.huihome.module.find_near_mine.activity.AfflatuspictoActivity;
import com.nostra13.universalimageloader.core.DisplayImageOptions;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/5/13.
 */
public class DesignerWorksAdapter extends MyBaseAdapter<DesignerWorks.BodyBean.WorkItemsBean> {
    private DisplayImageOptions options;
    private Context context;
    public DesignerWorksAdapter(Context context, List<DesignerWorks.BodyBean.WorkItemsBean> list) {
        super(context, list);
        this.context = context;
        options = BaseApplication.getApplication().getImageOptions();
    }

    @Override
    public int getLayoutId() {
        return R.layout.works_list_item;
    }

    @Override
    public BaseViewHolder getViewHolder() {
        return new ViewHolder();
    }

    @Override
    public void bindViews(View view, BaseViewHolder viewHolder) {
        final DesignerWorks.BodyBean.WorkItemsBean item = getItem(viewHolder.position);
        ViewHolder mHolder = (ViewHolder) viewHolder;
        mHolder.tvDesignThemeName.setText(item.getWorkname());
        mHolder.tvDesignStyle.setText(item.getDecoStyle());
        mHolder.tvHeartNum.setText(item.getAppraiseCount()+"");
        mHolder.tvMessageNum.setText(item.getCommentCount()+"");
        mHolder.tvShareNum.setText(item.getShareCount()+"");
        mHolder.tvUnitPrice.setText(item.getFee()+"元/㎡");
        BaseApplication.getApplication().getImageLoader().displayImage(item.getCoverimg(),mHolder.ivDesignImg,options);
        mHolder.rlClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, AfflatuspictoActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra("id",item.getId());
                context.startActivity(intent);
            }
        });
    }

    static class ViewHolder extends BaseViewHolder{
        @BindView(R.id.iv_design_img)
        ImageView ivDesignImg;
        @BindView(R.id.rl_click)
        RelativeLayout rlClick;
        @BindView(R.id.tv_unit_price)
        TextView tvUnitPrice;
        @BindView(R.id.tv_design_style)
        TextView tvDesignStyle;
        @BindView(R.id.tv_design_theme_name)
        TextView tvDesignThemeName;
        @BindView(R.id.tv_heart_num)
        TextView tvHeartNum;
        @BindView(R.id.tv_message_num)
        TextView tvMessageNum;
        @BindView(R.id.tv_share_num)
        TextView tvShareNum;

    }
}
